import { createAsyncThunk,createSlice } from "@reduxjs/toolkit";
import { getSellerApi } from "../../services/axios";



interface Seller {
    name:string
    avatar:string
    bulletin:string
    description:string
    deliveryPrice:number
    deliveryTime:number
    supports:{
        type:number
        description:string
    }[]
    infos:string[]
    pics:string[]
    minPrice:number
    foodScore:number
    ratingCount:number
    sellCount:number
    rankRate:number
    serviceScore:number
    score:number
}
interface initialStateList {
    sellerList:Seller | null
}


const initialState:initialStateList = {
    sellerList:null
}



export const getSeller = createAsyncThunk('seller/getSeller',async () => {
    const res = await getSellerApi()
    // console.log(res.data)
    return res.data.data
})


const sellerSlice = createSlice ({
    name:'seller',
    initialState,
    reducers:{

    },

    extraReducers: builder => {
        builder
          .addCase(getSeller.fulfilled, (state, action) => {
            // console.log(action.payload)
            state.sellerList = action.payload
          })
      }

})




export default sellerSlice.reducer